package com.demo.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.demo.entity.Department;
import com.demo.entity.DvtDiagnose;
import com.demo.entity.Vo.DepartmentRatioVo;
import com.demo.entity.Vo.DepartmentVo;
import com.demo.entity.Vo.DvtDiagonseVo;
import com.demo.entity.Vo.MessageSocketVo;
import com.demo.entity.VtePreventive;
import org.apache.catalina.LifecycleState;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.Date;
import java.util.List;

/**
 * dvt诊断表 Mapper 接口
 * @author zm
 * @since 2020-12
 */
public interface DvtDiagnoseMapper extends BaseMapper<DvtDiagnose> {

    /**
     *
     * @param clinicPossibility     临床可能性
     * @param dDimer                D-二聚体
     * @param venousPressure        静脉加压超声检查
     * @param wessMin               Wells评分min分
     * @param wessMax               Wells评分max分
     * @return
     */
    List<DvtDiagonseVo> getDvtList(@Param("clinicPossibility") Integer clinicPossibility, @Param("dDimer")Integer dDimer, @Param("venousPressure")Integer venousPressure, @Param("wessMin")Integer wessMin, @Param("wessMax")Integer wessMax);

    /**
     * 通过患者ID，查询患者做了DVT筛查的患者数
     * @param patientId
     * @return
     */
    List<Integer> getDvtSum(@Param("patientId")List<Integer> patientId);

    /**
     * 查询某个时间段，指定患者是否做了DVT筛查
     * @param patientId
     * @param startDate
     * @param endDate
     * @return
     */
    List<Integer> getDvtMonthSum(@Param("patientId")List<Integer> patientId, @Param("startDate") Date startDate,@Param("endDate") Date endDate);

    /**
     * 通过患者ID，查询患者做了DVT筛查的患者数[各个科室分别筛查数，取前五]
     * @param patientId
     * @return
     */
    List<DepartmentRatioVo> getDvtDepartmentSum(@Param("patientId")List<Integer> patientId, @Param("order") String order);

    List<MessageSocketVo> getDvtPreventiveIntervalDay(@Param("intervalDay") Integer paramInteger);

    Integer getDvtSumByDeptSn(@Param("deptSn") Integer paramInteger);

    List<DepartmentVo> getDvtRankByDeptSn(@Param("orderType") String paramString, @Param("topNumber") Integer paramInteger);

    Integer getDurationDvtSumByDeptSn(@Param("departments") List<Integer> paramList, @Param("startDate") Date paramDate1, @Param("endDate") Date paramDate2);

    @Select("select patient_id, max(dvt_diagnose_id) as dvt_diagnose_id from pd_dvt_diagnose where deleted_time is null and sign_time is not null and detect_advise = '一周后复查超声检查' group by patient_id")
    List<DvtDiagnose> queryRecentDvtDiagnose();

    @Select("select patient_id, dvt_diagnose_id from pd_dvt_diagnose where deleted_time is null and sign_time is not null and detect_advise = '一周后复查超声检查' and patient_id=#{patientId} order by sign_time desc limit 1")
    DvtDiagnose queryRecentDvtDiagnoseByPatientId(Integer patientId);
}
